<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * ElearningCard filter form base class.
 *
 * @package    elearning
 * @subpackage filter
 * @author     Your name here
 */
class BaseElearningCardFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'std_id'              => new sfWidgetFormFilterInput(),
      'class_id'            => new sfWidgetFormFilterInput(),
      'card_serial_number'  => new sfWidgetFormFilterInput(),
      'note'                => new sfWidgetFormFilterInput(),
      'el_card_active_time' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'el_card_status'      => new sfWidgetFormFilterInput(),
      'created_at'          => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at'          => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'el_card_user_status' => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'std_id'              => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'class_id'            => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'card_serial_number'  => new sfValidatorPass(array('required' => false)),
      'note'                => new sfValidatorPass(array('required' => false)),
      'el_card_active_time' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'el_card_status'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'created_at'          => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'          => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'el_card_user_status' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('elearning_card_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'ElearningCard';
  }

  public function getFields()
  {
    return array(
      'std_id'              => 'Number',
      'class_id'            => 'Number',
      'card_serial_number'  => 'Text',
      'note'                => 'Text',
      'el_card_active_time' => 'Date',
      'el_card_status'      => 'Number',
      'created_at'          => 'Date',
      'updated_at'          => 'Date',
      'el_card_user_status' => 'Number',
      'id'                  => 'Number',
    );
  }
}
